#include<bits/stdc++.h>
using namespace std;
int main(){ // 出租车计价
 	//freopen("taxi.in","r",stdin);
 	//freopen("taxi.out","w",stdout);
 	double a,b,s=0;
 	cin>>a>>b;
 	if(b==1){
 		if(a<=3){
 			s=9.0;
		}else{
			if(a<=6) s=(a-3)*1.5+9.0;
			else s=9.0+3*1.5+(a-6)*2.25;
		}
	}else{
 		if(a<=3){
 			s=9.0;
		}else{
			if(a<=6) s=(a-3)*1.75+9.0;
			else s=9.0+3*1.75+(a-6)*2.5;
		}
	}
	printf("%.2f",s);
 	return 0;
}